<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="Hexo Theme Keep">
    <meta name="description" content="Hexo Theme Keep">
    <meta name="author" content="YCR">
    
    <title>
        
            如何使用 Arduino Mega 2560 实现一个家庭智能安防门锁? |
        
        Ycr&#39;s Blog
    </title>
    
<link rel="stylesheet" href="/css/style.css">

    <link rel="shortcut icon" href="/images/logo.jpg">
    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/css/font-awesome.min.css">
    <script id="hexo-configurations">
    let KEEP = window.KEEP || {};
    KEEP.hexo_config = {"hostname":"ycr10.xyz","root":"/","language":"zh-CN","path":"search.xml"};
    KEEP.theme_config = {"toc":{"enable":true,"number":true,"expand_all":true,"init_open":true},"style":{"primary_color":"#0066CC","avatar":"/images/avatar.jpg","favicon":"/images/logo.jpg","article_img_align":"left","left_side_width":"260px","content_max_width":"920px","hover":{"shadow":true,"scale":true},"first_screen":{"enable":true,"background_img":"/images/bg.svg","description":"“喜欢你的人一直有空，什么都懂，无所不能。”"},"scroll":{"progress_bar":{"enable":false},"percent":{"enable":false}}},"local_search":{"enable":true,"trigger":"auto","unescape":false,"preload":true},"code_copy":{"enable":true,"style":"default"},"pjax":{"enable":true},"lazyload":{"enable":false},"version":"3.4.2"};
    KEEP.language_ago = {"second":"%s 秒前","minute":"%s 分钟前","hour":"%s 小时前","day":"%s 天前","week":"%s 周前","month":"%s 月前","year":"%s 年前"};
  </script>
<meta name="generator" content="Hexo 5.3.0"><link rel="alternate" href="/atom.xml" title="Ycr's Blog" type="application/atom+xml">
</head>


<body>
<div class="progress-bar-container">
    

    
        <span class="pjax-progress-bar"></span>
        <span class="pjax-progress-icon">
            <i class="fas fa-circle-notch fa-spin"></i>
        </span>
    
</div>


<main class="page-container">

    

    <div class="page-main-content">

        <div class="page-main-content-top">
            <header class="header-wrapper">

    <div class="header-content">
        <div class="left">
            <a class="logo-title" href="/">
                Ycr&#39;s Blog
            </a>
        </div>

        <div class="right">
            <div class="pc">
                <ul class="menu-list">
                    
                        <li class="menu-item">
                            <a class=""
                               href="/"
                            >
                                首页
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               target="_blank" rel="noopener" href="https://space.bilibili.com/474149759"
                            >
                                BILIBILI
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/archives"
                            >
                                归档
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/categories"
                            >
                                分类
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/tags"
                            >
                                标签
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/about"
                            >
                                关于
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/Links"
                            >
                                友链
                            </a>
                        </li>
                    
                    
                        <li class="menu-item search search-popup-trigger">
                            <i class="fas fa-search"></i>
                        </li>
                    
                </ul>
            </div>
            <div class="mobile">
                
                    <div class="icon-item search search-popup-trigger"><i class="fas fa-search"></i></div>
                
                <div class="icon-item menu-bar">
                    <div class="menu-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="header-drawer">
        <ul class="drawer-menu-list">
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/">首页</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       target="_blank" rel="noopener" href="https://space.bilibili.com/474149759">BILIBILI</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/archives">归档</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/categories">分类</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/tags">标签</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/about">关于</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/Links">友链</a>
                </li>
            
        </ul>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="page-main-content-middle">

            <div class="main-content">

                
                    <div class="fade-in-down-animation">
    <div class="article-content-container">

        <div class="article-title">
            <span class="title-hover-animation">如何使用 Arduino Mega 2560 实现一个家庭智能安防门锁?</span>
        </div>

        
            <div class="article-header">
                <div class="avatar">
                    <img src="/images/avatar.jpg">
                </div>
                <div class="info">
                    <div class="author">
                        <span class="name">YCR</span>
                        
                            <span class="author-label">Lv1</span>
                        
                    </div>
                    <div class="meta-info">
                        <div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fas fa-edit"></i>&nbsp;2021-02-13 12:45:02
    </span>
    
        <span class="article-categories article-meta-item">
            <i class="fas fa-folder"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/categories/%E6%99%BA%E8%83%BD%E7%A1%AC%E4%BB%B6/">智能硬件</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    
    
        <span class="article-tags article-meta-item">
            <i class="fas fa-tags"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/tags/Arduino/">Arduino</a>&nbsp;
                    </li>
                
                    <li>
                        | <a href="/tags/%E6%99%BA%E8%83%BD%E7%A1%AC%E4%BB%B6/">智能硬件</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    

    
    
    
    
        <span class="article-pv article-meta-item">
            <i class="fas fa-eye"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>
        </span>
    
</div>

                    </div>
                </div>
            </div>
        

        <div class="article-content markdown-body">
            <h1 id="如何使用-Arduino-Mega-2560-实现一个家庭智能安防门锁？"><a href="#如何使用-Arduino-Mega-2560-实现一个家庭智能安防门锁？" class="headerlink" title="如何使用 Arduino Mega 2560 实现一个家庭智能安防门锁？"></a>如何使用 Arduino Mega 2560 实现一个家庭智能安防门锁？</h1><p>说明视频见我的 <a class="link"   target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1bp4y1x7Sj" >Bilibili<i class="fas fa-external-link-alt"></i></a></p>
<h2 id="创作灵感"><a href="#创作灵感" class="headerlink" title="创作灵感"></a>创作灵感</h2><p>&nbsp; &nbsp; &nbsp; &nbsp;新冠肺炎疫情发生以来，习近平总书记高度重视，多次主持召开会议对疫情防控工作进行研究部署，并对如何发挥社区在疫情防控中的作用提出明确要求。习近平总书记指出，要压实地方党委和政府责任，强化社区防控网格化管理，实施地毯式排查，采取更加严格、更有针对性、更加管用有效的措施，防止疫情蔓延。</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;本人以社区和家庭疫情防控为出发点，设计了一款智慧防疫门禁系统。本次设计的作品能够实现刷卡，蓝牙开锁等方式开启家庭门锁，同时实时监测人的体温，贴心的提示外出回家的人员消毒。防止体温过热人员回家接触家人，造成病情蔓延。</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;这样一个可以让人们在享受智慧家居便利性的同时，又能监测健康状况的智慧防疫门禁系统，能够很好地配合社区疫情防控，做好家庭防疫工作。</p>
<h2 id="设计思路"><a href="#设计思路" class="headerlink" title="设计思路"></a>设计思路</h2><p>&nbsp; &nbsp; &nbsp; &nbsp;这是一种无接触式的门锁，自然就要用到现在成熟的无线技术了。在这种小型门锁中，蓝牙技术再好不过了。再利用<code>RFID-RC522</code>模块，也能实现NFC通信。</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; 疫情期间，大家对自己的健康也有极大的要求。家庭门锁也要实时监控自己的体温以及客人的体温。如果你的体温超过37.3摄氏度，那智能门锁也会利用LED灯以及蜂鸣器来警告你，同时也会紧闭门锁，做好疫情防控第一步。</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;直观的设计思路以及功能原理图如图1所示：</p>
<p><img src="https://s3.ax1x.com/2021/03/05/6mBbGD.png"></p>
<p>图1 设计思路及功能原理图</p>
<h2 id="硬件一览"><a href="#硬件一览" class="headerlink" title="硬件一览"></a>硬件一览</h2><blockquote>
<p>主控板：</p>
<p>Arduino Mega 2560 *1</p>
<p>配件：</p>
<p>RFID-RC522模块 *1</p>
<p>DX-BT05蓝牙模块 *1</p>
<p>FL-3FF-S-Z继电器模块 *1</p>
<p>蜂鸣器 *1</p>
<p>电磁锁 *1</p>
<p>LED *3</p>
<p>220Ω电阻 *3</p>
</blockquote>
<h2 id="接线图"><a href="#接线图" class="headerlink" title="接线图"></a>接线图</h2><table>
<thead>
<tr>
<th align="center">模块名称</th>
<th align="center">模块针脚</th>
<th align="center">Aruduino Mega针脚</th>
</tr>
</thead>
<tbody><tr>
<td align="center">Relay Mode</td>
<td align="center">VCC</td>
<td align="center">5V</td>
</tr>
<tr>
<td align="center">Relay Mode</td>
<td align="center">GND</td>
<td align="center">GND</td>
</tr>
<tr>
<td align="center">Relay Mode</td>
<td align="center">IN</td>
<td align="center">D5</td>
</tr>
<tr>
<td align="center">RFID-RC522</td>
<td align="center">IRQ</td>
<td align="center">D10</td>
</tr>
<tr>
<td align="center">RFID-RC522</td>
<td align="center">SCK</td>
<td align="center">D8</td>
</tr>
<tr>
<td align="center">RFID-RC522</td>
<td align="center">MOSI</td>
<td align="center">D9</td>
</tr>
<tr>
<td align="center">RFID-RC522</td>
<td align="center">MISO</td>
<td align="center">D11</td>
</tr>
<tr>
<td align="center">RFID-RC522</td>
<td align="center">SDA</td>
<td align="center">D7</td>
</tr>
<tr>
<td align="center">RFID-RC522</td>
<td align="center">RST</td>
<td align="center">D12</td>
</tr>
<tr>
<td align="center">RFID-RC522</td>
<td align="center">3.3V</td>
<td align="center">3.3V</td>
</tr>
<tr>
<td align="center">RFID-RC522</td>
<td align="center">GND</td>
<td align="center">GND</td>
</tr>
<tr>
<td align="center">Buzzer</td>
<td align="center">GND</td>
<td align="center">GND</td>
</tr>
<tr>
<td align="center">Buzzer</td>
<td align="center">VCC</td>
<td align="center">5V</td>
</tr>
<tr>
<td align="center">Buzzer</td>
<td align="center">I/O</td>
<td align="center">D2</td>
</tr>
<tr>
<td align="center">DX-BT05</td>
<td align="center">GND</td>
<td align="center">GND</td>
</tr>
<tr>
<td align="center">DX-BT05</td>
<td align="center">VCC</td>
<td align="center">5V</td>
</tr>
<tr>
<td align="center">DX-BT05</td>
<td align="center">TX</td>
<td align="center">RX</td>
</tr>
<tr>
<td align="center">DX-BT05</td>
<td align="center">RX</td>
<td align="center">TX</td>
</tr>
<tr>
<td align="center">DX-BT05</td>
<td align="center">EN</td>
<td align="center">5V</td>
</tr>
<tr>
<td align="center">mlx90614</td>
<td align="center">GND</td>
<td align="center">GND</td>
</tr>
<tr>
<td align="center">mlx90614</td>
<td align="center">VCC</td>
<td align="center">VCC</td>
</tr>
<tr>
<td align="center">mlx90614</td>
<td align="center">SDA</td>
<td align="center">SDA</td>
</tr>
<tr>
<td align="center">mlx90614</td>
<td align="center">SCL</td>
<td align="center">SCL</td>
</tr>
<tr>
<td align="center">LED-Red</td>
<td align="center">GND</td>
<td align="center">GND</td>
</tr>
<tr>
<td align="center">LED-Red</td>
<td align="center">VCC</td>
<td align="center">220Ω电阻端</td>
</tr>
<tr>
<td align="center">LED-Yellow</td>
<td align="center">GND</td>
<td align="center">GND</td>
</tr>
<tr>
<td align="center">LED-Yellow</td>
<td align="center">VCC</td>
<td align="center">220Ω电阻端</td>
</tr>
<tr>
<td align="center">LED-Green</td>
<td align="center">GND</td>
<td align="center">GND</td>
</tr>
<tr>
<td align="center">LED-Green</td>
<td align="center">VCC</td>
<td align="center">220Ω电阻端</td>
</tr>
<tr>
<td align="center">220Ω电阻</td>
<td align="center">一端</td>
<td align="center">5V</td>
</tr>
<tr>
<td align="center">220Ω电阻</td>
<td align="center">另一端</td>
<td align="center">LED</td>
</tr>
</tbody></table>
<hr>
<p>仿真接线图如下</p>
<p><img src="https://s3.ax1x.com/2021/03/05/6mBHPO.png"></p>
<p>图2 仿真接线图</p>
<h2 id="制作过程"><a href="#制作过程" class="headerlink" title="制作过程"></a>制作过程</h2><ol>
<li>准备木板，设计家庭木门外观：<ul>
<li>使用切割机切割木板，得到前门和侧门</li>
<li>在前门中间安装电磁锁</li>
</ul>
</li>
</ol>
<p><img src="https://s3.ax1x.com/2021/03/05/6mBIVx.jpg"></p>
<ol>
<li>门板正面外观和组装设计：<ul>
<li>使用电钻钻出三个LED发光二极管</li>
<li>在门板上沿安装红外温度检测模块</li>
<li>在门板上沿安装LCD液晶显示屏</li>
<li>在门板右上角画门禁图案</li>
</ul>
</li>
</ol>
<p><img src="https://s3.ax1x.com/2021/03/05/6mBoa6.jpg"></p>
<ol start="3">
<li>门板背面外观和组装设计<ul>
<li>安装电池盒和继电器开关</li>
<li>安装Arduino电路板</li>
<li>安装门禁卡</li>
</ul>
</li>
</ol>
<p><img src="https://s3.ax1x.com/2021/03/05/6mBTIK.jpg"></p>
<ol start="4">
<li>组装木板以及组接各个模块<ul>
<li>将木板前门和侧边墙壁组装</li>
<li>接线并通电</li>
</ul>
</li>
</ol>
<p><img src="https://s3.ax1x.com/2021/03/05/6mBqRe.jpg"></p>
<ol start="5">
<li>测试各个模块功能以及两种开锁方式<ul>
<li>IC门禁卡开锁</li>
<li>手机蓝牙开锁</li>
</ul>
</li>
</ol>
<p><img src="https://s3.ax1x.com/2021/03/05/6mBLxH.jpg"><br><img src="https://s3.ax1x.com/2021/03/05/6mBXMd.jpg"></p>
<h2 id="成品外观"><a href="#成品外观" class="headerlink" title="成品外观"></a>成品外观</h2><p><img src="https://s3.ax1x.com/2021/03/05/6mBjsA.jpg"></p>
<p>图3 成品外观正面</p>
<p><img src="https://s3.ax1x.com/2021/03/05/6mBzZt.jpg"></p>
<p>图4 成品外观侧面</p>
<p><img src="https://s3.ax1x.com/2021/03/05/6mBvqI.jpg"></p>
<p>图5 成品外观背面</p>
<p><img src="https://s3.ax1x.com/2021/03/05/6mDSdP.jpg"></p>
<p>图6 成品外观俯视图</p>
<h2 id="使用说明"><a href="#使用说明" class="headerlink" title="使用说明"></a>使用说明</h2><p>&nbsp; &nbsp; &nbsp; &nbsp;这个家庭智能门锁提供多种开锁方式，你可以使用IC卡或者手机蓝牙打开他它。</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;门锁上有三个LED灯，若红灯常亮即为待机状态;绿灯亮起，蜂鸣器鸣叫两声，表示锁已打开;黄灯闪烁两次，蜂鸣器鸣叫三声，表示体温过高;红绿黄三灯亮起，蜂鸣器长鸣，即表示密码错误。</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;当你想要使用IC卡进行开锁操作，仅需将正确的IC卡放置到读卡区域，IC卡读到后，将会自动打开。使用蓝牙开锁时，仅需连接上<code>Smart-lock</code>蓝牙，通过串口发送密码，即可打开门锁。</p>
<h2 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&quot;rfid1.h&quot;</span> <span class="comment">//调用读卡器模块库文件</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;Adafruit_MLX90614.h&quot;</span> <span class="comment">//调用温度传感器库文件</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;LiquidCrystal_I2C.h&quot;</span> <span class="comment">//调用LCD库文件</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;Wire.h&gt; //调用库文件</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> uchar unsigned char</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> uint  unsigned int</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> ull unsigned long long</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> Red  45</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> Green 47</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> Yellow 49</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> Buzzer 2</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> Relay 5</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> IRQ 10</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> SCK 8</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> MOSI 9</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> MISO 11</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> SDA 7</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> RST 12 <span class="comment">//接口定义 详情见说明文档接线图</span></span></span><br><span class="line">RFID1 rfid;</span><br><span class="line">Adafruit_MLX90614 mlx = Adafruit_MLX90614(); <span class="comment">//测温模块初始化</span></span><br><span class="line"><span class="function">LiquidCrystal_I2C <span class="title">lcd</span><span class="params">(<span class="number">0x27</span>,<span class="number">16</span>,<span class="number">2</span>)</span></span>; <span class="comment">//lcd模块初始化</span></span><br><span class="line">uchar serNum[<span class="number">5</span>];</span><br><span class="line">uchar a;</span><br><span class="line">uint b; </span><br><span class="line"><span class="keyword">double</span> tem; <span class="comment">//一些用于记录数据的变量 数组</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">setup</span><span class="params">()</span> <span class="comment">//初始化函数</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  Serial.begin(<span class="number">9600</span>); <span class="comment">//电脑(测试)串口初始化</span></span><br><span class="line">  Serial2.begin(<span class="number">9600</span>); <span class="comment">//蓝牙模块串口初始化</span></span><br><span class="line">  pinMode(Buzzer,OUTPUT);</span><br><span class="line">  pinMode(Relay,OUTPUT); </span><br><span class="line">  pinMode(Red,OUTPUT);</span><br><span class="line">  pinMode(Yellow,OUTPUT);</span><br><span class="line">  pinMode(Green,OUTPUT); <span class="comment">//IO引脚声明</span></span><br><span class="line">  rfid.begin(IRQ,SCK,MOSI,MISO,SDA,RST); <span class="comment">//RFID模块引脚声明</span></span><br><span class="line">  mlx.begin(); <span class="comment">//温度计初始化</span></span><br><span class="line">  rfid.init(); <span class="comment">//RFID初始化</span></span><br><span class="line">  lcd.init(); <span class="comment">//lcd模块初始化</span></span><br><span class="line">  lcd.backlight(); <span class="comment">//lcd模块背光</span></span><br><span class="line">  lcd.print(<span class="string">&quot;   Smart-lock   &quot;</span>); <span class="comment">//lcd输出</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">TEM</span><span class="params">()</span> <span class="comment">//测温函数</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  Serial.println(mlx.readObjectTempC()+<span class="number">5</span>); <span class="comment">//调试串口输出</span></span><br><span class="line">  tem=mlx.readObjectTempC()+<span class="number">5</span>; <span class="comment">//常量赋值</span></span><br><span class="line">  <span class="keyword">return</span> tem+<span class="number">5</span>; <span class="comment">//返回读取的温度值</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">open</span><span class="params">()</span> <span class="comment">//开门函数</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">if</span>(tem&lt;=<span class="number">37.3</span>) <span class="comment">//如果体温不超过37.3摄氏度，即可开门</span></span><br><span class="line">  &#123;</span><br><span class="line">    lcd.clear();</span><br><span class="line">    lcd.setCursor(<span class="number">0</span>,<span class="number">0</span>);</span><br><span class="line">    lcd.print(<span class="string">&quot;Temperature OK&quot;</span>);</span><br><span class="line">    lcd.setCursor(<span class="number">0</span>,<span class="number">1</span>);</span><br><span class="line">    lcd.print(<span class="string">&quot;Temp is: &quot;</span>);</span><br><span class="line">    lcd.print(tem);</span><br><span class="line">    lcd.print(<span class="string">&quot;*C&quot;</span>); <span class="comment">//lcd输出</span></span><br><span class="line">    Serial.println(<span class="string">&quot;Temperature OK&quot;</span>); <span class="comment">//调试串口输出</span></span><br><span class="line">    Serial2.println(<span class="string">&quot;Temperature OK&quot;</span>); <span class="comment">//蓝牙串口输出</span></span><br><span class="line">    Serial.print(<span class="string">&quot;Turn on.&quot;</span>); <span class="comment">//调试串口输出</span></span><br><span class="line">    Serial2.print(<span class="string">&quot;Turn on.&quot;</span>); <span class="comment">//蓝牙串口输出</span></span><br><span class="line">    digitalWrite(Red,LOW);</span><br><span class="line">    digitalWrite(Green,HIGH);</span><br><span class="line">    digitalWrite(Relay,LOW);</span><br><span class="line">    digitalWrite(Buzzer,LOW); <span class="comment">//绿灯亮起，并打开电磁锁（继电器）</span></span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Buzzer,HIGH);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Buzzer,LOW);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Buzzer,HIGH); <span class="comment">//蜂鸣器鸣叫两声，代表锁已开</span></span><br><span class="line">    digitalWrite(Relay,HIGH); <span class="comment">//锁关闭</span></span><br><span class="line">    digitalWrite(Green,LOW);</span><br><span class="line">    digitalWrite(Red,HIGH); <span class="comment">//红灯重新亮起</span></span><br><span class="line">    lcd.clear();</span><br><span class="line">    lcd.setCursor(<span class="number">0</span>,<span class="number">0</span>);</span><br><span class="line">    lcd.print(<span class="string">&quot;   Smart-lock   &quot;</span>); <span class="comment">//lcd输出</span></span><br><span class="line">    Serial.print(<span class="string">&quot;Turn off.&quot;</span>); <span class="comment">//调试串口输出</span></span><br><span class="line">    Serial2.print(<span class="string">&quot;Turn off.&quot;</span>); <span class="comment">//蓝牙串口输出</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">else</span> <span class="comment">//体温超过37.3摄氏度</span></span><br><span class="line">  &#123;</span><br><span class="line">    lcd.clear();</span><br><span class="line">    lcd.setCursor(<span class="number">0</span>,<span class="number">0</span>);</span><br><span class="line">    lcd.print(<span class="string">&quot;Temperature HIGH&quot;</span>);</span><br><span class="line">    lcd.setCursor(<span class="number">0</span>,<span class="number">1</span>);</span><br><span class="line">    lcd.print(<span class="string">&quot;Temp is: &quot;</span>);</span><br><span class="line">    lcd.print(tem);</span><br><span class="line">    lcd.print(<span class="string">&quot;*C&quot;</span>); <span class="comment">//lcd输出</span></span><br><span class="line">    Serial.println(<span class="string">&quot;Temperature HIGH&quot;</span>); <span class="comment">//调试串口输出</span></span><br><span class="line">    Serial2.println(<span class="string">&quot;Temperature HIGH&quot;</span>); <span class="comment">//蓝牙串口输出</span></span><br><span class="line">    digitalWrite(Red,LOW);</span><br><span class="line">    digitalWrite(Yellow,HIGH);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Yellow,LOW);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Yellow,HIGH);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Yellow,LOW);</span><br><span class="line">    digitalWrite(Red,HIGH); <span class="comment">//黄灯闪烁两次，红灯重新亮起</span></span><br><span class="line">    digitalWrite(Buzzer,LOW);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Buzzer,HIGH);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Buzzer,LOW);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Buzzer,HIGH);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Buzzer,LOW);</span><br><span class="line">    delay(<span class="number">100</span>);</span><br><span class="line">    digitalWrite(Buzzer,HIGH); <span class="comment">//蜂鸣器鸣叫三声，表示温度过高</span></span><br><span class="line">    lcd.clear();</span><br><span class="line">    lcd.print(<span class="string">&quot;   Smart-lock   &quot;</span>); <span class="comment">//lcd输出</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">loop</span><span class="params">()</span> <span class="comment">//主循环函数</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  uchar status;</span><br><span class="line">  uchar str[MAX_LEN];</span><br><span class="line">  digitalWrite(Relay,HIGH);</span><br><span class="line">  digitalWrite(Buzzer,HIGH);</span><br><span class="line">  digitalWrite(Red,HIGH);</span><br><span class="line">  digitalWrite(Yellow,LOW);</span><br><span class="line">  digitalWrite(Green,LOW); <span class="comment">//初始化</span></span><br><span class="line">  TEM(); <span class="comment">//测温</span></span><br><span class="line">  status = rfid.request(PICC_REQIDL, str);</span><br><span class="line">  rfid.showCardType(str);</span><br><span class="line">  status=rfid.anticoll(str);</span><br><span class="line">  <span class="keyword">if</span>(status==MI_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Serial.print(<span class="string">&quot;The card&#x27;s number is: &quot;</span>); <span class="comment">//调试串口输出</span></span><br><span class="line">    <span class="built_in">memcpy</span>(serNum,str,SCK);</span><br><span class="line">    rfid.showCardID(serNum);</span><br><span class="line">    Serial.println();</span><br><span class="line">    Serial.println();</span><br><span class="line">  &#125;</span><br><span class="line">  uchar* id=serNum; <span class="comment">//读取卡的ID  </span></span><br><span class="line">  <span class="keyword">if</span>(Serial2.available()&gt;<span class="number">0</span>)  <span class="comment">//如果蓝牙模块串口有读到信息</span></span><br><span class="line">  &#123;</span><br><span class="line">    a=Serial2.read(); <span class="comment">//蓝牙串口读取</span></span><br><span class="line">    b=<span class="number">1</span>; <span class="comment">//一个用于记录是否执行的变量</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">if</span>(id[<span class="number">0</span>]==<span class="number">0xCA</span> &amp;&amp; id[<span class="number">1</span>]==<span class="number">0xD9</span> &amp;&amp; id[<span class="number">2</span>]==<span class="number">0xF0</span> &amp;&amp; id[<span class="number">3</span>]==<span class="number">0x3F</span>) <span class="comment">//如果读到了正确的卡</span></span><br><span class="line">  &#123;</span><br><span class="line">    open(); <span class="comment">//执行开门函数</span></span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;=<span class="number">3</span>;i++) id[i]=<span class="number">0</span>; <span class="comment">//初始值返回0</span></span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;=<span class="number">3</span>;i++) serNum[i]=<span class="number">0</span>; <span class="comment">//初始值返回0</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">else</span> <span class="comment">//如果不是正确的卡</span></span><br><span class="line">  &#123;</span><br><span class="line">    <span class="keyword">if</span>(status==MI_OK) <span class="comment">//且有读到卡，执行不开门</span></span><br><span class="line">    &#123;</span><br><span class="line">      lcd.clear();</span><br><span class="line">      lcd.println(<span class="string">&quot;Password Error&quot;</span>);  <span class="comment">//lcd输出</span></span><br><span class="line">      digitalWrite(Yellow,HIGH);</span><br><span class="line">      digitalWrite(Green,HIGH);</span><br><span class="line">      digitalWrite(Buzzer,LOW); <span class="comment">//红黄蓝三灯常亮，蜂鸣器响起</span></span><br><span class="line">      delay(<span class="number">3000</span>);</span><br><span class="line">      digitalWrite(Buzzer,HIGH);</span><br><span class="line">      digitalWrite(Yellow,LOW);</span><br><span class="line">      digitalWrite(Green,LOW); <span class="comment">//灯熄灭，蜂鸣器停止，代表密码错误</span></span><br><span class="line">      lcd.clear();</span><br><span class="line">      lcd.print(<span class="string">&quot;   Smart-lock   &quot;</span>);  <span class="comment">//lcd输出</span></span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">if</span>(a==<span class="string">&#x27;a&#x27;</span>) <span class="comment">//如果蓝牙串口读到密码</span></span><br><span class="line">  &#123;</span><br><span class="line">    b=<span class="number">0</span>; <span class="comment">//记录的变量值归零</span></span><br><span class="line">    open(); <span class="comment">//执行开门函数</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">else</span> <span class="comment">//若密码错误</span></span><br><span class="line">  &#123;</span><br><span class="line">    <span class="keyword">if</span>(b==<span class="number">1</span>) <span class="comment">//且有接收到数据，执行不开门</span></span><br><span class="line">    &#123;</span><br><span class="line">      lcd.clear();</span><br><span class="line">      lcd.println(<span class="string">&quot;Password Error&quot;</span>);  <span class="comment">//lcd输出</span></span><br><span class="line">      digitalWrite(Yellow,HIGH);</span><br><span class="line">      digitalWrite(Green,HIGH);</span><br><span class="line">      digitalWrite(Buzzer,LOW); <span class="comment">//红黄蓝三灯常亮，蜂鸣器响起</span></span><br><span class="line">      delay(<span class="number">3000</span>);</span><br><span class="line">      digitalWrite(Buzzer,HIGH);</span><br><span class="line">      digitalWrite(Yellow,LOW);</span><br><span class="line">      digitalWrite(Green,LOW); <span class="comment">//灯熄灭，蜂鸣器停止，代表密码错误</span></span><br><span class="line">      lcd.clear(); </span><br><span class="line">      lcd.println(<span class="string">&quot;Password Error&quot;</span>);  <span class="comment">//lcd输出</span></span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">  rfid.halt(); <span class="comment">//RFID-RC522重置</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
        </div>

        

        
            <div class="article-nav">
                
                    <div class="article-prev">
                        <a class="prev"
                           rel="prev"
                           href="/2021/03/05/%E4%B8%AA%E4%BA%BA%E7%8E%AF%E5%A2%83%E7%AE%80%E4%BB%8B-NO-1-Wsl-2/"
                        >
                            <span class="left arrow-icon flex-center">
                              <i class="fas fa-chevron-left"></i>
                            </span>
                            <span class="title flex-center">
                                <span class="post-nav-title-item">个人环境简介 NO.1 - Wsl 2</span>
                                <span class="post-nav-item">上一篇</span>
                            </span>
                        </a>
                    </div>
                
                
                    <div class="article-next">
                        <a class="next"
                           rel="next"
                           href="/2021/02/13/%E5%AF%84%E7%94%9F%E8%99%AB-%E5%BD%B1%E8%AF%84%E6%91%98%E5%BD%95/"
                        >
                            <span class="title flex-center">
                                <span class="post-nav-title-item">寄生虫 影评摘录</span>
                                <span class="post-nav-item">下一篇</span>
                            </span>
                            <span class="right arrow-icon flex-center">
                              <i class="fas fa-chevron-right"></i>
                            </span>
                        </a>
                    </div>
                
            </div>
        

        
            <div class="comment-container">
                <div class="comments-container">
    <div id="comment-anchor"></div>
    <div class="comment-area-title">
        <i class="fas fa-comments">&nbsp;评论</i>
    </div>
    

        
            
    <div class="valine-container">
        <script data-pjax
                src="//cdn.jsdelivr.net/npm/valine@latest/dist/Valine.min.js"></script>
        <div id="vcomments"></div>
        <script data-pjax>
            function loadValine() {
                new Valine({
                    el: '#vcomments',
                    appId: 'hGzCvE6RESemcTo8gfkul9hV-gzGzoHsz',
                    appKey: 'SSqOtE9IVhhPOk8oXCi6KjEV',
                    meta: ['nick', 'mail', 'link'],
                    avatar: 'wavatar',
                    enableQQ: true,
                    placeholder: '😜 尽情吐槽吧~',
                    lang: 'zh-CN'.toLowerCase()
                });

                function getAuthor(language) {
                    switch (language) {
                        case 'en':
                            return 'Author';
                        case 'zh-CN':
                            return '博主';
                        default:
                            return 'Master';
                    }
                }

                // Add "Author" identify
                const getValineDomTimer = setInterval(() => {
                    const vcards = document.querySelectorAll('#vcomments .vcards .vcard');
                    if (vcards.length > 0) {
                        let author = 'YCR';

                        if (author) {
                            for (let vcard of vcards) {
                                const vnick_dom = vcard.querySelector('.vhead .vnick');
                                const vnick = vnick_dom.innerHTML;
                                if (vnick === author) {
                                    vnick_dom.innerHTML = `${vnick} <span class="author">${getAuthor(KEEP.hexo_config.language)}</span>`
                                }
                            }
                        }
                        clearInterval(getValineDomTimer);
                    } else {
                        clearInterval(getValineDomTimer);
                    }
                }, 2000);
            }

            if ('true') {
                const loadValineTimeout = setTimeout(() => {
                    loadValine();
                    clearTimeout(loadValineTimeout);
                }, 1000);
            } else {
                window.addEventListener('DOMContentLoaded', loadValine);
            }
        </script>
    </div>



        
    
</div>

            </div>
        
    </div>
</div>


                
            </div>

        </div>

        <div class="page-main-content-bottom">
            <footer class="footer">
    <div class="info-container">
        <div class="copyright-info info-item">
            &copy;
            
              <span>2020</span>&nbsp;-&nbsp;
            
            2021&nbsp;<i class="fas fa-heart icon-animate"></i>&nbsp;<a href="/">YCR</a>
        </div>
        
            <script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            <div class="website-count info-item">
                
                    <span id="busuanzi_container_site_uv">
                        访问人数&nbsp;<span id="busuanzi_value_site_uv"></span>&ensp;
                    </span>
                
                
                    <span id="busuanzi_container_site_pv">
                        总访问量&nbsp;<span id="busuanzi_value_site_pv"></span>
                    </span>
                
            </div>
        
        <div class="theme-info info-item">
            由 <a target="_blank" href="https://hexo.io">Hexo</a> 驱动&nbsp;|&nbsp;主题&nbsp;<a class="theme-version" target="_blank" href="https://github.com/XPoet/hexo-theme-keep">Keep v3.4.2</a>
        </div>
        
    </div>
</footer>

        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="tools-list">
        <!-- TOC aside toggle -->
        
            <li class="tools-item page-aside-toggle">
                <i class="fas fa-outdent"></i>
            </li>
        

        <!-- go comment -->
        
            <li class="go-comment">
                <i class="fas fa-comment"></i>
            </li>
        
    </ul>
</div>

        </div>
    

    <div class="right-bottom-side-tools">
        <div class="side-tools-container">
    <ul class="side-tools-list">
        <li class="tools-item tool-font-adjust-plus flex-center">
            <i class="fas fa-search-plus"></i>
        </li>

        <li class="tools-item tool-font-adjust-minus flex-center">
            <i class="fas fa-search-minus"></i>
        </li>

        <li class="tools-item tool-expand-width flex-center">
            <i class="fas fa-arrows-alt-h"></i>
        </li>

        <li class="tools-item tool-dark-light-toggle flex-center">
            <i class="fas fa-moon"></i>
        </li>

        <!-- rss -->
        

        
            <li class="tools-item tool-scroll-to-top flex-center">
                <i class="fas fa-arrow-up"></i>
            </li>
        

        <li class="tools-item tool-scroll-to-bottom flex-center">
            <i class="fas fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="exposed-tools-list">
        <li class="tools-item tool-toggle-show flex-center">
            <i class="fas fa-cog fa-spin"></i>
        </li>
        
    </ul>
</div>

    </div>

    
        <aside class="page-aside">
            <div class="post-toc-wrap">
    <div class="post-toc">
        <ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8-Arduino-Mega-2560-%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA%E5%AE%B6%E5%BA%AD%E6%99%BA%E8%83%BD%E5%AE%89%E9%98%B2%E9%97%A8%E9%94%81%EF%BC%9F"><span class="nav-number">1.</span> <span class="nav-text">如何使用 Arduino Mega 2560 实现一个家庭智能安防门锁？</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%9B%E4%BD%9C%E7%81%B5%E6%84%9F"><span class="nav-number">1.1.</span> <span class="nav-text">创作灵感</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%AE%BE%E8%AE%A1%E6%80%9D%E8%B7%AF"><span class="nav-number">1.2.</span> <span class="nav-text">设计思路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A1%AC%E4%BB%B6%E4%B8%80%E8%A7%88"><span class="nav-number">1.3.</span> <span class="nav-text">硬件一览</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8E%A5%E7%BA%BF%E5%9B%BE"><span class="nav-number">1.4.</span> <span class="nav-text">接线图</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%88%B6%E4%BD%9C%E8%BF%87%E7%A8%8B"><span class="nav-number">1.5.</span> <span class="nav-text">制作过程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%88%90%E5%93%81%E5%A4%96%E8%A7%82"><span class="nav-number">1.6.</span> <span class="nav-text">成品外观</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E"><span class="nav-number">1.7.</span> <span class="nav-text">使用说明</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81"><span class="nav-number">1.8.</span> <span class="nav-text">代码</span></a></li></ol></li></ol>
    </div>
</div>
        </aside>
    

    <div class="image-viewer-container">
    <img src="">
</div>


    
        <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
          <span class="search-input-field-pre">
            <i class="fas fa-keyboard"></i>
          </span>
            <div class="search-input-container">
                <input autocomplete="off"
                       autocorrect="off"
                       autocapitalize="off"
                       placeholder="搜索..."
                       spellcheck="false"
                       type="search"
                       class="search-input"
                >
            </div>
            <span class="popup-btn-close">
                <i class="fas fa-times"></i>
            </span>
        </div>
        <div id="search-result">
            <div id="no-result">
                <i class="fas fa-spinner fa-pulse fa-5x fa-fw"></i>
            </div>
        </div>
    </div>
</div>

    

</main>



<script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/utils.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/main.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/header-shrink.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/back2top.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/dark-light-toggle.js"></script>


    <script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/local-search.js"></script>



    <script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/code-copy.js"></script>




<div class="post-scripts pjax">
    
        <script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/left-side-toggle.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/libs/anime.min.js"></script><script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/toc.js"></script>
    
</div>


    <script src="//cdn.jsdelivr.net/npm/hexo-theme-keep@3.4.2/source/js/libs/pjax.min.js"></script>
<script>
    window.addEventListener('DOMContentLoaded', () => {
        const pjax = new Pjax({
            selectors: [
                'head title',
                '.page-container',
                '.pjax'
            ],
            history: true,
            debug: false,
            cacheBust: false,
            timeout: 0,
            analytics: false,
            currentUrlFullReload: false,
            scrollRestoration: false,
            // scrollTo: true,
        });

        document.addEventListener('pjax:send', () => {
            KEEP.utils.pjaxProgressBarStart();
        });

        document.addEventListener('pjax:complete', () => {
            KEEP.utils.pjaxProgressBarEnd();
            pjax.executeScripts(document.querySelectorAll('script[data-pjax], .pjax script'));
            KEEP.refresh();
        });
    });
</script>



</body>
</html>
